package com.moli.iov.handle.alarm.enums;

import java.util.HashSet;
import java.util.Set;

/**
 * <p>
 *
 * </p>
 *
 * @author zql
 * @since 2019/6/17 9:55
 */
public enum AlarmLevelEnum {

    /**
     *  一级
     */
    ONE(1, "一级"),

    /**
     * 二级
     */
    PLATFORM(2, "二级"),

    /**
     * 三级
     */
    THREE(3, "三级");

    private int flag;

    private String msg;

    AlarmLevelEnum(int flag, String msg){
        this.flag = flag;
        this.msg = msg;
    }

    public static AlarmLevelEnum getEnum(int flag){
        for(AlarmLevelEnum e : AlarmLevelEnum.values()){
            if(e.flag == flag){
                return e;
            }
        }
        return null;
    }

    public static String getMsg(int flag){
        for(AlarmLevelEnum e : AlarmLevelEnum.values()){
            if(e.flag == flag){
                return e.msg;
            }
        }
        return "";
    }

    public static Set<Integer> getLevels(){
        Set<Integer> set =new HashSet<>();
        for(AlarmLevelEnum e : AlarmLevelEnum.values()){
            set.add(e.getFlag());
        }
        return set;
    }

    public int getFlag() {
        return flag;
    }

    public String getMsg() {
        return msg;
    }
}
